$(document).ready(function () {

    $("#userName, #password").keyup(function (event) {
        if (event.keyCode == 13) {
            $("#login_button").click();
        }
    });

    $("#login_button").click(function () {
        var userName = $("#userName").val();
        var password = $("#password").val();
        var rmbpwd = $("#rmbpwd").val();
        if (userName == '') {
            $("#alertInfo").parent().removeClass('hide');
            $("#errorMsg").html("请输入用户名！");
            return false;
        }
        if (password == '') {
            $("#alertInfo").parent().removeClass('hide');
            $("#errorMsg").html("请输入密码！");
            return false;
        }
        $.post("/Admin/login/doLogin", {
            userName: userName,
            password: password,
            rmbpwd: rmbpwd
        }, function (data) {
            if (data.code == 10000) {
                window.location.href = '/Admin/Category';
            } else {
                alert(data.message);
            }
        }, "json");
    });
});